package org.example.mytest.newControler;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.mytest.newMapper.GoodsMapper;
import org.example.mytest.newMapper.InventorylogsMapper;
import org.example.mytest.newMapper.WarehouseMapper;
import org.example.mytest.newentity.*;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/warehouse")
@MapperScan("org.example.mytest.newMapper")
public class LianjieControler
{
    @Autowired
    WarehouseMapper warehouseMapper;
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    InventorylogsMapper inventorylogsMapper;
    @GetMapping("/findByPage/{page}/{size}")
    public IPage findByPage(@PathVariable("page") Integer page,
                            @PathVariable("size") Integer size){
        //设置起始值及每页数
        Page<goods> pages = new Page<>(page,size);
        IPage iPage=goodsMapper.selectPage(pages,null);
        System.out.println(iPage);
        return iPage;
    }
    @GetMapping("query")
    public List query2() {
        List<warehouse> list =warehouseMapper.getWarehouseAndUsers();
        return list;
    }
    @PostMapping("/save")
    public int save(@RequestBody warehouse users){

        int result = warehouseMapper.insert(users);
        return result;
    }
    @GetMapping("query1")
    public List query3() {
        List<goods> list =goodsMapper.getWarehouseAndGoodss();
        return list;
    }
    @CrossOrigin
    @PostMapping("/save2")
    public int save(@RequestBody goods goods){

        int result = goodsMapper.insert(goods);
        return result;
    }
    @GetMapping("inven")
    public List query5() {
        List<inventorylogs> list =inventorylogsMapper.getinvenAndUsers();
        return list;
    }


}




